from datetime import datetime
import pytz

from celery import Celery
from celery.schedules import crontab

from scraper import main as scraper_main
from data_statistics import main as data_statistics_main
import utils


app = Celery(
    'scraper_vkusvill',
    broker='redis://localhost:6379',
    timezone = pytz.timezone('Europe/Moscow') 
)

utils.run_necessary_task(app)

@app.task
def parsing_all_products() -> None:
    """ Парсим все продукты """
    list_of_passed_arguments = utils.InputDataFromUser().get_list_of_passed_arguments()
    scraper_main.main(
        list_of_passed_arguments.what_parse
    )


@app.task
def parse_specified_products() -> None:
    """ Парсим указанные продукты """

    list_of_passed_arguments = utils.InputDataFromUser().get_list_of_passed_arguments()
    scraper_main.main(
        list_of_passed_arguments.what_parse
    )


@app.task
def send_statistics_of_specified_products() -> None:
    """ Отправляем статистику указанных продуктов """
    data_statistics_main.main(
        type_of_statistics='specified_products'
    )
